package com.ruoyi.college.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.college.domain.LabCollege;
import com.ruoyi.college.service.ILabCollegeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 校区管理Controller
 * 
 * @author winner pan
 * @date 2022-02-13
 */
@RestController
@RequestMapping("/college/college")
public class LabCollegeController extends BaseController
{
    @Autowired
    private ILabCollegeService labCollegeService;

    /**
     * 查询校区管理列表
     */
    @PreAuthorize("@ss.hasPermi('college:college:list')")
    @GetMapping("/list")
    public TableDataInfo list(LabCollege labCollege)
    {
        startPage();
        List<LabCollege> list = labCollegeService.selectLabCollegeList(labCollege);
        return getDataTable(list);
    }

    /**
     * 导出校区管理列表
     */
    @PreAuthorize("@ss.hasPermi('college:college:export')")
    @Log(title = "校区管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LabCollege labCollege)
    {
        List<LabCollege> list = labCollegeService.selectLabCollegeList(labCollege);
        ExcelUtil<LabCollege> util = new ExcelUtil<LabCollege>(LabCollege.class);
        return util.exportExcel(list, "college");
    }

    /**
     * 获取校区管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('college:college:query')")
    @GetMapping(value = "/{collegeId}")
    public AjaxResult getInfo(@PathVariable("collegeId") Long collegeId)
    {
        return AjaxResult.success(labCollegeService.selectLabCollegeById(collegeId));
    }

    /**
     * 新增校区管理
     */
    @PreAuthorize("@ss.hasPermi('college:college:add')")
    @Log(title = "校区管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabCollege labCollege)
    {
        return toAjax(labCollegeService.insertLabCollege(labCollege));
    }

    /**
     * 修改校区管理
     */
    @PreAuthorize("@ss.hasPermi('college:college:edit')")
    @Log(title = "校区管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabCollege labCollege)
    {
        return toAjax(labCollegeService.updateLabCollege(labCollege));
    }

    /**
     * 删除校区管理
     */
    @PreAuthorize("@ss.hasPermi('college:college:remove')")
    @Log(title = "校区管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{collegeIds}")
    public AjaxResult remove(@PathVariable Long[] collegeIds)
    {
        return toAjax(labCollegeService.deleteLabCollegeByIds(collegeIds));
    }
}
